/*
    SDL - Simple DirectMedia Layer
    Copyright (C) 1997-2009 Sam Lantinga

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA

    Sam Lantinga
    slouken@libsdl.org
*/

#include "../SDL_cellvideo.h"
#include "SDL_cellpadmap.h"

#ifndef CELL_NO_SOFT_INPUT

/* Enter mouse mode */
void							CELL_PAD_MOUSE_Enter				(enum PadMode aOldMode)
{
	SDL_ResetKeyboard();
	CELL_ReleaseAllMouseButtons();
}

/* Exit mouse mode */
void							CELL_PAD_MOUSE_Exit					(enum PadMode aNewMode)
{
	SDL_ResetKeyboard();
	CELL_ReleaseAllMouseButtons();
}

/* Handle Axis functions for mouse mode */
void FASTCALL					CELL_PAD_MOUSE_Axes					(int32_t aXAxis, int32_t aYAxis)
{
	int xaxis = (aXAxis - 0x80) / 16;
	int yaxis = (aYAxis - 0x80) / 16;

	if(xaxis || yaxis)
	{
		SDL_PrivateMouseMotion(0, 1, xaxis, yaxis);
	}
}

/* Handle button functions for mouse mode */
void FASTCALL 					CELL_PAD_MOUSE_Buttons				(uint32_t aNewButtons, uint32_t aOldButtons)
{
	for(int i = 0; i != NUM_BUTTONS; i ++)
	{
		if((CELL_Video.Pads.ButtonMap[i].Nullify == 0) && CELL_Video.Pads.ButtonMap[i].Mapped)
		{
			CELL_PAD_ProcessButton(i, aNewButtons & (1 << i), aOldButtons & (1 << i));
		}
	}
}

#endif
